﻿@model IEnumerable<AntDesigner.GameCityBase.Notice>
@{
    Layout = "~/Views/Shared/_LayoutHaveManue.cshtml";
}
<h2>公告列表</h2>
<a href="/Manage/Index/">返回</a>
<script type="text/javascript">
    function deleteNotice(id) {
        $.ajax(
            {
                url: "/manage/deletenotice/",
                type: 'post',
                datatype: 'text',
                data: { noticeid: id },
                beforeSend: function () {
                    confirm("是否要删除?");

                },
                success: function () {
                    $("#" + id).remove();
                }
            })
    }
    function modifyNotice(id, content) {
        $.ajax({
            url: "/Manage/modifyNotice/",
            type: 'post',
            dataType: 'text',
            data: { noticeId: id, newContent: content },
            success: function () {
                alert("修改完成");
            }
        })
    }
</script>
@{
    foreach (var notice in Model)
    {
        <div id="@notice.Id">
            <button type="button" class="btn btn-warning btn-xs  text-center" value="删除" onclick="deleteNotice(@notice.Id)">
                <span class="glyphicon glyphicon-trash"></span> 删除
            </button>
            <button type="button" class="btn btn-warning btn-xs  text-center" onclick="modifyNotice(@notice.Id,$('#content@(notice.Id)').val())" value="保存">
                <span class="glyphicon glyphicon-floppy-saved"></span> 保存
            </button>
            发布日期 @notice.CreateTime
            <textarea id="content@(notice.Id)" class="form-control" rows="4">@notice.Content</textarea>
        </div><br />
    }
}
